package cn.wolfcode.wolf2w.util;

/**
 * Created by 甘静斌 on 2020-08-08 13:09
 */

import cn.wolfcode.wolf2w.exception.LoginException;
import lombok.Getter;
import org.springframework.util.StringUtils;

/**
 *
 * 参数断言的判断工具
 */
@Getter
public class AssertUtil {

    private AssertUtil() {}

    /**
     * 判断传入参数value是否有值
     * @param value
     * @param msg
     */
    public static void hasLength(String value,String msg){

        if (!StringUtils.hasLength(value)){

            throw new LoginException(msg);
        }
    }

    public static void isEquals(String password, String rpassword, String msg) {

        if (password == null || rpassword == null ){
            throw new LoginException("输入的值不能为空");
        }

        if (!password.equals(rpassword)){

            throw new LoginException(msg);
        }
    }
}
